package com.ruoyi.web.studentmanagementsystem.service.impl;

import com.ruoyi.web.studentmanagementsystem.dto.*;
import com.ruoyi.web.studentmanagementsystem.mapper.SysSubjectMapper;
import com.ruoyi.web.studentmanagementsystem.pojo.SysSubject;
import com.ruoyi.web.studentmanagementsystem.service.ISysSubjectService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * ClassName: SysSubjectServiceImpl
 * Package: com.ruoyi.web.studentmanagementsystem.service.impl
 * Description:科目管理 服务实现
 *
 * @Author Mr. o
 * @Create 2023/11/11 20:45
 * @Version 1.0
 */
@Service
public class SysSubjectServiceImpl implements ISysSubjectService {
    @Resource
    private SysSubjectMapper subjectMapper;



    /**
     * 新增保存科目信息
     *
     * @param subject 科目信息
     * @return
     */
    @Override
    @Transactional
    public void insertSubject(ISysSubjectDTO subject) {
        subject.setCreateTime(new Date());
        subjectMapper.insertSubject(subject);
    }

    /**
     * 删除成绩信息
     *
     * @param studentId 学生ID
     * @return
     */
    @Override
    @Transactional
    public void deleteSubject(String studentId) {
        subjectMapper.deleteSubject(studentId);
    }

    /**
     * 根据学生ID查询信息
     *
     * @param studentId 学生ID
     * @return
     */
    @Override
    @Transactional
    public List<SysSubject> selectSubject(String studentId) {
        return subjectMapper.selectSubject(studentId);
    }

    /**
     * 修改保存科目信息
     *
     * @param subject 科目信息
     * @return
     */
    public void updateSubject(IISysSubjectDTO subject) {
        subject.setUpdateTime(new Date());
        subjectMapper.updateSubject(subject);
    }
}
